<template>
    <div :style="styleObject">
        <!--<div :id="id" :style="styleObject"></div>-->
        <div :id="id" :style="styleObject"></div>
    </div>
</template>
<script>

    export default {
        props: ['id', 'value', 'width', 'height', 'uploadImgUrl', 'disabled', 'mapKey', 'menuFixed', 'pasteFilter', 'codeDefaultLang', 'hideLinkImg', 'uploadParams', 'uploadHeaders', 'isRealtime', 'disabledMenus', 'useQiniu'],
        data() {
            return {
                styleObject: {
                    width: 'auto',
                    height: 'auto'
                },
                editor: null
            }
        },
        methods: {
            // 设置尺寸
            initSize() {
                if (this.width) {
                    this.styleObject.width = this.width + 'px'
                }
                if (this.height) {
                    this.styleObject.height = this.height + 'px'
                }
            },
            // 创建编辑器
            createEditor() {
                if (!document.getElementById(this.id)) {
                    setTimeout(() => {
                        this.createEditor(this.id)
                    }, 100);
                    return
                }
                this.editor = UE.getEditor(this.id);
            },
            // 获取内容(html)
            getHtml() {
                return this.editor.getContent()
            },
            // 获取内容(纯文本)
            getText() {
                return this.editor.getContentTxt();
            },
            //设置内容(html)
            setHtml(html){
                let app = this;
                setTimeout(() => {
                    return app.editor.setContent(html);

                },800)
            },
            //判断编辑器是否有内容
            hasContents(){
                return this.editor.hasContents();
            }
        },
        created() {
            this.initSize();
            this.createEditor()
        }
    }
</script>
